<template>
  <u-picker
    :show="show"
    ref="uPicker"
    :round="true"
    :columns="columns"
    :defaultIndex="defaultIndex"
    @confirm="confirm"
    @close="close"
    @cancel="close"
    closeOnClickOverlay
  ></u-picker>
</template>
<script>
export default {
  props: {
    show: Boolean,
    defaultVal:{
      type:Array
    }
  },
  data() {
    return {
      columns: [[...new Array(10)].map((_,i)=>2024+i),[...new Array(12)].map((_,i)=>i+1)],
      defaultIndex:[0,0]
    };
  },
  mounted(){
    console.log(this.columnData)
    console.log(this.columns)
  },
  watch:{
    show(val){
      if(val){
        this.$set(this.defaultIndex,0,this.defaultVal[0])
        this.$set(this.defaultIndex,1,this.defaultVal[1])
        console.log('====',this.defaultIndex)
      }
    }
  },
  methods: {
    close(){
        this.$emit('close')
    },
    confirm(e) {
      console.log("confirm", e);
      this.$emit('confirm',e)
    //   this.show = false;
    },
  },
};
</script>
